package doc;


import geom.Point;

import java.awt.geom.Point2D;


public class SampledPoint {


	private final double x;

	private final double y;

	private final int time;

	public SampledPoint(double _x, double _y, int _t) {
		x = _x;
		y = _y;
		time = _t;
	}

	public SampledPoint(double _x, double _y) {
		this(_x, _y, 0);
	}

	public SampledPoint(Point point) {
		this(point.getX(), point.getY());
	}

	public int getTime() {
		return time;
	}

	public double getX() {
		return x;
	}

	public double getY() {
		return y;
	}

	public Point2D toPoint2D() {
		return new Point2D.Double(getX(), getY());
	}

	public Point toPoint() {
		return new Point(getX(), getY());
	}

	public boolean equals(SampledPoint mate) {
		return toPoint().identical(mate.toPoint());
	}

	public String toSimpleML() {
		return toPoint().toString();
	}

	public static SampledPoint parseSimpleML(String string) {
		return new SampledPoint(Point.parsePoint(string));
	}

	public SampledPoint add(Point vector) {
		return new SampledPoint(getX() + vector.getX(), getY() + vector.getY(), getTime());
	}

	public String toString() {
		return "(" + getX() + "," + getY() + ")";
	}

}
